import Vue from 'vue'
import Vuex from 'vuex'

import {
  sysLinkSourceQuery,
  sysLinkSourceDelete,
  sysLinkSourceAdd,
  sysLinkSourceUpdate,
  sysLinkSourceOpenApiQuery,
} from '@/api/module/sysLinkSource'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async querySysLinkSource({ commit }, listQuery) {
    let res = await sysLinkSourceQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteSysLinkSource({ commit }, row) {
    let res = await sysLinkSourceDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addSysLinkSource({ commit }, data) {
    let res = await sysLinkSourceAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateSysLinkSource({ commit }, data) {
    let res = await sysLinkSourceUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async queryOpenApiSysLinkSource({ commit }, listQuery) {
    let res = await sysLinkSourceOpenApiQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
